package com.yonyou.pmclouds.siteinspection.configuration;

import com.yonyou.pmclouds.basecom.conf.FilterLevelConst;
import com.yonyou.pmclouds.siteinspection.filter.SiteInspectionFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import java.util.Arrays;

/**
 * 注册检查记录测试数据过滤器
 *
 * @author zhangzhonghao
 */

@Configuration
public class SiteInspectionFilterConfiguration {

    private static final String[] URL_PATTERN_ANY = {"/mobile/siteinspection/add", "/mobile/constructionlog/add",
            "/mobile/comprehensiveacceptance/add","/mobile/constructionlog/update","/mobile/comprehensiveacceptance/update"};

    @Bean
    public FilterRegistrationBean siteInspectionFilter() {
        Filter filter = new SiteInspectionFilter();
        FilterRegistrationBean bean = new FilterRegistrationBean(filter);
        bean.setUrlPatterns(Arrays.asList(URL_PATTERN_ANY));
        bean.setOrder(FilterLevelConst.LEVEL_FIRST + 1);
        bean.setName("siteInspectionFilter");
        return bean;
    }
}
